import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Personnel, PersonnelService } from './personnel.service';

@Injectable({
	providedIn: 'root',
})
export class DetailsService implements Resolve<Personnel> {
	constructor(private personnelService: PersonnelService) {}
	async resolve(route: ActivatedRouteSnapshot) {
		const id = Number(route.queryParamMap.get('id'));
		const personnel = await this.personnelService.get(id);
		return personnel;
	}
}
